Skip to content

adding TTL option for redis cache adapter#3397

Merged
acinader merged 8 commits into
parse-community:masterfrom
f0ster:master
Feb 27, 2017
Merged

adding TTL option for redis cache adapter#3397
acinader merged 8 commits into
parse-community:masterfrom
f0ster:master

Conversation

@f0ster

@f0ster f0ster commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@acinader

Copy link
Copy Markdown
Contributor

@f0ster this looks good to me. would you be willing to write a unit test that proves that the default constructor value works as expected?

@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

@f0ster

f0ster commented Jan 23, 2017

Copy link
Copy Markdown
Contributor Author

@acinader I will take a look, I didn't see any unit tests for the other cache adapters testing parameters so I didn't include..

@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

@f0ster

f0ster commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

Comment thread src/Adapters/Cache/RedisCacheAdapter.js Outdated
import logger from '../../logger';

const DEFAULT_REDIS_TTL = 30 * 1000; // 30 seconds in milliseconds
const DEFAULT_REDIS_TTL = 30; // 30 seconds in milliseconds

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment not true anymore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@f0ster why the change here?

https://github.com/f0ster/parse-server/blob/947471bc00c3b049278b61e0707b2f64cac13605/src/Adapters/Cache/RedisCacheAdapter.js#L50

we use psetex https://redis.io/commands/psetex

so if i've got it right, this change is not good? cause we'll just cache for 30 millis by default.

PS sorry for the delay.

Comment thread spec/RedisCacheAdapter.spec.js Outdated
cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))
.then(wait.bind(null, 50))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice idiom.


cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what!@?! mind blown. I don't even understand how returning expect.... is "thenable", but super cool idiom. going to start using....

@acinader

acinader commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

@f0ster super nice tests. thanks. just one outstanding issue on seconds v millis.

@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

@f0ster

f0ster commented Feb 22, 2017

Copy link
Copy Markdown
Contributor Author

@acinader I've gone ahead and updated the default ttl to use ms

Arthur Cinader and others added 2 commits February 22, 2017 22:14
make timeout values really really small so our test run fast :).
Fix the redis cache spec to construct the cache with the anticipated ttl
@facebook-github-bot

Copy link
Copy Markdown

@f0ster updated the pull request - view changes

@acinader

Copy link
Copy Markdown
Contributor

Grrrr, not sure why that test is failing. Obviously it works locally and may just be that the times are too short! And it passed once and failed once :(

In any event I'd like to play with it a bit to see if I can reproduce, understand and fix, but it'll take a few days before I can look at it.

@acinader

Copy link
Copy Markdown
Contributor

So I couldn't reproduce the problem and when i re-ran the test it worked. So I am going to merge this now and i'll watch the tests over the next few days. if this sucker keeps failing i'll increase the tolerances.

@acinader acinader merged commit e6006e8 into parse-community:master Feb 27, 2017
@f0ster

f0ster commented Mar 1, 2017

Copy link
Copy Markdown
Contributor Author

@acinader Awesome, thank you. I was also unable to reproduce, perhaps it was some sort of race condition ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants